#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>

using namespace std;

const int N = 2010;
int a[N][N];

int main()
{
	string s;
	while (getline(cin, s))
	{
		vector<char> ch;
		for (int k = 0; k < s.size(); k++)
		{
			if (s[k] ==  '^' || s[k] == '!' || s[k] == ')' || s[k] == '(')
				cout << s[k] << " ";
			else if (s[k] == '|' || s[k] == '-')
			{
				if (s[k] == '|') cout << "||" << " ";
				else cout << "->" << " ";
				k++;
			}
			else if (s[k] == '<')
			{
				cout << "<->" << " ";
				k += 2;
			}
			else if (s[k] >= 'a' && s[k] <= 'z')
			{
				ch.push_back(s[k]);
				cout << s[k] << " ";
			}
		}

		cout << endl;

		//逻辑变量的输出
		sort(ch.begin(), ch.end()); //排序
		ch.erase(unique(ch.begin(), ch.end()),ch.end()); //取出
		for (auto e : ch) //遍历
		{
			cout << e << " ";
		}
		cout << endl;
		
		int t = 1, cnt;
		int len = ch.size();
		bool f;
		for (int i = 1; i <= len; i++)
		{
			cnt = 0;
			f = true;
			for (int j = 1; j <= (1 << len); j++)
			{
				if (f) {
					a[j][i] = 1;
					cnt++;
				}
				else {
					a[j][i] = 0;
					cnt++;
				}
				if (cnt == t) {
					f ^= 1; //异或
					cnt = 0;
				}
			}
			t = t * 2;
		}

		for (int i = 1; i <= (1 << len); i++)
		{
			for (int j = len; j > 0; j--)
			{
				if (j == 1) printf("%d\n", a[i][j]); //最后一个打印换行
				else printf("%d ", a[i][j]);
			}
		}
	}

	return 0;
}